
#pragma once

#include "core/olisp_core.h"
#include "utility/olisp_quote_mgr.h"

#define ADDREF( s ) s->vtbl->add_ref(s)
#define RELEASE( s ) s->vtbl->release(s)

/*
 *  identifier
 */

STATIC_INLINE const char * id_as_str( id_obj_t * s )
{ return s->vtbl->as_str( s ); }

STATIC_INLINE lisp_hash_t id_as_hash( id_obj_t * s )
{ return s->vtbl->as_hash( s ); }

/*
 * number
 */
STATIC_INLINE int num_as_int( num_obj_t * s )
{ return s->vtbl->as_int( s ); }

STATIC_INLINE double num_as_double( num_obj_t * s )
{ return s->vtbl->as_double( s ); }

STATIC_INLINE int num_is_double( num_obj_t * s )
{ return s->vtbl->is_double( s ); }

/*
 *  string
 */

STATIC_INLINE const char * str_get_str( str_obj_t * s )
{ return s->vtbl->get_str( s ); }

/*
 * list class
 */

STATIC_INLINE size_t list_length( list_obj_t * s )
{ return s->vtbl->length(s); }

STATIC_INLINE obj_t * list_get_elem( list_obj_t * s, size_t pos )
{ return s->vtbl->get_elem(s, pos); }

STATIC_INLINE int list_insert(
    list_obj_t * s, obj_t * elem, size_t pos, int after )
{ return s->vtbl->insert(s, elem, pos, after); }

STATIC_INLINE int list_append( list_obj_t * s, obj_t * elem )
{ return s->vtbl->append(s, elem); }

STATIC_INLINE int list_set( list_obj_t * s, size_t pos, obj_t * elem )
{ return s->vtbl->set(s, pos, elem); }

STATIC_INLINE int list_remove( list_obj_t * s, obj_t * elem )
{ return s->vtbl->remove(s, elem); }


#ifdef LISP_FEAT_QUOTE_SUPPORT
/*
 * quote manager functions
 */

STATIC_INLINE void quote_mgr_dispose( lisp_quote_mgr_t * self )
{ self->vtbl->dispose( self ); }

STATIC_INLINE void quote_mgr_set_marker(
    lisp_quote_mgr_t * self, obj_t * elem, int quote_marker )
{ self->vtbl->set_quote_marker( self, elem, quote_marker ); }

STATIC_INLINE int quote_mgr_get_marker(
        lisp_quote_mgr_t * self, obj_t * elem )
{ return self->vtbl->get_quote_marker( self, elem ); }
#endif

